package com.wutong.eams.other;

import com.wutong.eams.utils.ObjectUtil;

import java.util.HashMap;
import java.util.Map;

public record JsonMap(Map<String, Object> map) {

    public static JsonMap create() {
        return new JsonMap(new HashMap<>());
    }

    public JsonMap put(String key, Object value) {
        map.put(key, value);
        return this;
    }

    public JsonMap putAll(Map<String, Object> map) {
        this.map.putAll(map);
        return this;
    }

    public Object get(String key) {
        return map.get(key);
    }

    public boolean containsKey(String key) {
        return map.containsKey(key);
    }

    public boolean isEmpty() {
        return map.isEmpty();
    }

    public int size() {
        return map.size();
    }

    public String buildToJson() {
        return ObjectUtil.toJson(map);
    }

    public Map<String, Object> buildToMap() {
        return map;
    }

}
